{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Workfunction of hcp (0001) surfaces\n",
    "\n",
    "In this notebook, we will show how to calculate the workfunction of selected hcp(0001) surfaces using [VASP](https://www.vasp.at/). Please keep in mind that the parameters used here give no converged results. They have been chosen to demonstrate the workflow using inexpensive calculations. For converged results, parameters such as lattice parameters, plane-wave energy cutoffs, reciprocal space sampling or the need to perform spin polarized calculations have to be carefully chosen "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "%matplotlib inline \n",
    "import matplotlib.pylab as plt\n",
    "import pandas as pd\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pyiron.project import Project"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "pr = Project(\"hcp_workfunction\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Calculating the Workfunction of Mg(0001) \n",
    "\n",
    "### Structure creation\n",
    "We use the `create_surface()` function which uses the ASE surface generator to build our surface slab structure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "99239e67eb69452d8bda5e262b3fb7fb",
       "version_major": 2,
       "version_minor": 0
      },
      "text/html": [
       "<p>Failed to display Jupyter Widget of type <code>NGLWidget</code>.</p>\n",
       "<p>\n",
       "  If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n",
       "  that the widgets JavaScript is still loading. If this message persists, it\n",
       "  likely means that the widgets JavaScript library is either not installed or\n",
       "  not enabled. See the <a href=\"https://ipywidgets.readthedocs.io/en/stable/user_install.html\">Jupyter\n",
       "  Widgets Documentation</a> for setup instructions.\n",
       "</p>\n",
       "<p>\n",
       "  If you're reading this message in another frontend (for example, a static\n",
       "  rendering on GitHub or <a href=\"https://nbviewer.jupyter.org/\">NBViewer</a>),\n",
       "  it may mean that your frontend doesn't currently support widgets.\n",
       "</p>\n"
      ],
      "text/plain": [
       "NGLWidget()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    " # Now we set-up the Mg (0001) surface\n",
    "a = 3.1919\n",
    "c = 5.1852\n",
    "\n",
    "# Vacuum region to break the periodicity along the z-axis\n",
    "vac = 10\n",
    "size = (2, 2, 4)\n",
    "Mg_0001 = pr.create_surface(\"Mg\", \n",
    "                            surface_type=\"hcp0001\", \n",
    "                            size=size, \n",
    "                            a=a, \n",
    "                            c=c, \n",
    "                            orthogonal=True, \n",
    "                            vacuum=vac)\n",
    "Mg_0001.plot3d()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Using selective dynamics\n",
    "\n",
    "We use selective dynamics to restrict relaxation to the surface atoms (first and last Mg layers). We use the advanced array indexing options available in the NumPy package (see [here](https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html)) to detect which atoms are at the surface and then freeze the rest"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Initially freeze all the atoms\n",
    "Mg_0001.add_tag(selective_dynamics=[False, False, False])\n",
    "\n",
    "# Find which atoms are at the surface \n",
    "# (based on the z-coordinate)\n",
    "pos_z = Mg_0001.positions[:, 2]\n",
    "z_min, z_max = np.min(pos_z), np.max(pos_z)\n",
    "eps = 1e-4\n",
    "relax_indices = np.argwhere(((pos_z - eps) > z_min) \n",
    "                            & ((pos_z + eps) < z_max ))\n",
    "relax_indices  = relax_indices.flatten()\n",
    "\n",
    "# Now allow these atoms to relax\n",
    "\n",
    "Mg_0001.selective_dynamics[relax_indices] = [True, True, True]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Setup and execution\n",
    "\n",
    "To automate the calculation we define a function that has as input the project object, structure, job_name, Fermi smearing width, the type of k-point sampling and the plane-wave energy cutoff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_ham(proj, basis, name, sigma=0.1, mesh=\"GP\", encut=350):\n",
    "    ham = proj.create_job(pr.job_type.Vasp, name)\n",
    "    ham.set_convergence_precision(electronic_energy=1e-7, \n",
    "                                  ionic_energy=1e-2)\n",
    "    # Setting fermi-smearing\n",
    "    ham.set_occupancy_smearing(smearing=\"fermi\", width=sigma)\n",
    "    # Ionic_minimization\n",
    "    ham.calc_minimize(ionic_steps=100, \n",
    "                      electronic_steps=60, \n",
    "                      retain_electrostatic_potential=True, \n",
    "                      pressure=None)\n",
    "    ham.structure = basis\n",
    "    ham.set_encut(encut=encut)\n",
    "    if mesh == \"GP\":\n",
    "        # Only the Gamma point\n",
    "        ham.set_kpoints(scheme=\"GP\")\n",
    "    elif len(mesh) == 3:\n",
    "        ham.set_kpoints(mesh=mesh)\n",
    "    return ham"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "ham_vasp = get_ham(proj=pr, \n",
    "                   basis=Mg_0001, \n",
    "                   name=\"Mg_0001\", \n",
    "                   sigma=0.1, \n",
    "                   mesh=\"GP\", \n",
    "                   encut=350)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Submitting to the queue (optional)\n",
    "\n",
    "If you use a cluster installation of pyiron, you can send the created jobs to the cluster by specifying the name of the queue and the number of cores"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "# queue = ham_vasp.server.list_queues()[-1]\n",
    "# ham_vasp.server.queue = queue\n",
    "# ham_vasp.server.cores = 20\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choosing an appropriate executable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['5.3',\n",
       " '5.3_col',\n",
       " '5.3_col_mpi',\n",
       " '5.3_mpi',\n",
       " '5.4',\n",
       " '5.4.4',\n",
       " '5.4.4_gam',\n",
       " '5.4.4_gam_mpi',\n",
       " '5.4.4_mpi',\n",
       " '5.4.4_ncl',\n",
       " '5.4.4_ncl_mpi',\n",
       " '5.4.4_std',\n",
       " '5.4.4_std_mpi',\n",
       " '5.4_gamma',\n",
       " '5.4_gamma_mpi',\n",
       " '5.4_mpi']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ham_vasp.executable.available_versions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Since this example uses the $\\Gamma$ point only, we can use the VASP Gamma-only version. If you use more k-points choose an appropriate executable"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "ham_vasp.executable.version = \"5.4_gamma\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Execution\n",
    "\n",
    "The job is ready for execution"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "ham_vasp.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Post processing\n",
    "\n",
    "To analyze the results we ensure that the job is finished (the `if` statement in the first line). We then compute the work function by subtracting the Fermi-level from the vacuum level\n",
    "\n",
    "$\\Phi = V_{vac} - \\epsilon_F$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wf: 3.37343565133\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAY4AAAEPCAYAAABV6CMBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxv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oQMtalQjoaiWB2skG0Gs4hZVa9cX0cGjVk8kZlj2qXi8/nEBRdccNpj733ve/EXf/EXiMViuP766896z2233YbbbrsNw8PDeM973nPac13hGOKrrsaJn38JQwN9+MAHPnDa86/3T6D1yvdix/c+h0OHDuGjH/3oWcf/whe+gGuvvRa7d+/GnXfeedbzX/7yl3HppZfixRdfxOc///mznr/33nuxefNmPP300/jiF7941vPf/e53sXbtWjz66KP4xje+MfX4saEoxmJpvP78Y2htbcXPf/5z3H///We9/5e//CXu+OVhHP/j4/B1//Gs55944gl4PB58+9vfxi9+8Yuznv/9738PAPj617+Oxx577LTn3G43fv3rXwMA/uEf/gHPPPPMac/X1NTgoYceAgDcfffdeOmll057vqWlBd633IkD/RGc3/c/2L1792nPr1mzBl3rb4XfbUfljh/i8OHDpz2/efNm3HvvvQCAW2+9FT09Pac9f8kll+ArX/kKAODd7343RkZGTnv+mmuuwd/8zd8AAN761rciHj99oNwNN9yAu+66CwDwxje+8azfzRHvRtz2kdtxz1tWFn3tAcAdd9yBm2++Gd3d3WddewDw6U9/Gm9/+9tNd+2p/PjHP5732qutrcUDDzyABx544KznZV97P/nJTwAAd95554zX3rZt2wAAt99+u7RrbyiSROuGDrTXeNEQcE09X+x977nnntshhOg464VnwB5HAUzE02iv8cJlt874fKXbju7RmCn3uIilsvA4Zrb7TM5rqUTvWBxmXEvs6BybtSoMUDrgd3eNIWuySb/pbA6JdBYr6tjjYPSjtsIBm9WCeNqgXKsQYtH9ueCCC4RWRBJpseLux8XXnzw462te6xkTyz77mHhkV49mn6sF6UxWrL7nCfGlx18v6PX/s7tXLPvsY2J/77jOlhXHyeGoWPbZx8SPXzo562se3aPY/lrPmIGWzc8rx0fEss8+Jn53cFC2Kcwi5z33/1H8r/tfLOsYALaLAu6x7HHMw/aTYWRzAhctn70qaW2DDw6bxfBBY/NxYngSqUwO5zQWVs2zJh+HPxKK6GlW0ezoVAoPOtpn9zjMmtxXE/ar2ONgdGZVvQ+HDfrusnDMw47OUVgth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KYoWDgYhmGYomDhYBiGYYqChYNhGIYpChYOhmEYpij+P5LI2ZuPfDgCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x2ab9e8daaf28>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "if ham_vasp.status.finished:\n",
    "    # Get the electrostatic potential\n",
    "    epot = ham_vasp.get_electrostatic_potential()\n",
    "    \n",
    "    # Compute the lateral average along the z-axis (ind=2)\n",
    "    epot_z = epot.get_average_along_axis(ind=2)\n",
    "    \n",
    "    # Get the final relaxed structure from the simulation\n",
    "    struct = ham_vasp.get_structure(iteration_step=-1)\n",
    "    r = np.linalg.norm(struct.cell[2])\n",
    "    z = np.linspace(0, r, len(epot_z))\n",
    "    \n",
    "    # Computing the vacuum-level\n",
    "    vac_level = np.max(epot_z)\n",
    "    \n",
    "    # Get the electronic structure\n",
    "    es = ham_vasp.get_electronic_structure()\n",
    "    print(\"wf:\", vac_level - es.efermi)\n",
    "    plt.plot(z, epot_z - vac_level)\n",
    "    plt.xlim(0, r)\n",
    "    plt.axhline(es.efermi - vac_level,\n",
    "                color=\"black\", \n",
    "                linestyle=\"dashed\")\n",
    "    plt.xlabel(\"z ($\\AA$)\")\n",
    "    plt.ylabel(\"V - V$_{vac}$\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Looping over a series of hcp(0001) surfaces\n",
    "\n",
    "We now repeat the workflow for a set of hcp metals (the chosen lattice parameters are approximate). Note that if you use the same naming convention, pyiron detects that a job with the same name exists (\"Mg_0001\") and loads the output from this calculation rather than launch a new job with the same name."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "hcp_dict = {\"Zn\": {\"a\":2.6649, \"c\": 4.9468}, \n",
    "            \"Mg\": {\"a\": 3.1919, \"c\": 5.1852}, \n",
    "            \"Co\": {\"a\": 2.5071 , \"c\": 4.0695},\n",
    "            \"Ru\": {\"a\": 2.7059 , \"c\": 4.2815}}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "vac = 10\n",
    "size = (2, 2, 4)\n",
    "for element, lattice_parameters in hcp_dict.items():\n",
    "    surf = pr.create_surface(element, \n",
    "                             surface_type=\"hcp0001\", \n",
    "                             size=size, \n",
    "                             a=lattice_parameters[\"a\"], \n",
    "                             c=lattice_parameters[\"c\"], \n",
    "                             orthogonal=True, vacuum=vac)\n",
    "    surf.add_tag(selective_dynamics=[False, False, False])\n",
    "    pos_z = surf.positions[:, 2]\n",
    "    z_min, z_max = np.min(pos_z), np.max(pos_z)\n",
    "    eps = 1e-4\n",
    "    relax_indices = np.argwhere(((pos_z - eps) > z_min) \n",
    "                                & ((pos_z + eps) < z_max ))\n",
    "    relax_indices  = relax_indices.flatten()\n",
    "    surf.selective_dynamics[relax_indices] = [True, True, True]\n",
    "    job_name = \"{}_0001\".format(element)\n",
    "    ham = get_ham(pr, surf, \n",
    "                  name=job_name,\n",
    "                  sigma=0.1, \n",
    "                  mesh=\"GP\", \n",
    "                  encut=350)\n",
    "    #ham.server.cores = 20\n",
    "    #ham.server.queue = queue\n",
    "    ham.executable.version = '5.4_gamma'\n",
    "    ham.run()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Loading and analyzing\n",
    "Now we iterate over all jobs in this project and calculate the workfunction. We also time how long the cell takes to execute"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time: 9.250723838806152s\n"
     ]
    }
   ],
   "source": [
    "t1 = time.time()\n",
    "for ham in pr.iter_jobs():\n",
    "    if ham.status.finished:\n",
    "            final_struct = ham.get_structure(iteration_step=-1)\n",
    "            elec_structure = ham.get_electronic_structure()\n",
    "            e_Fermi = elec_structure.efermi\n",
    "            epot = ham.get_electrostatic_potential()\n",
    "            epot_z = epot.get_average_along_axis(ind=2)\n",
    "            vacuum_level = np.max(epot_z)\n",
    "            wf = vacuum_level - e_Fermi\n",
    "            element = final_struct.get_majority_species()[-1]\n",
    "            hcp_dict[element][\"work_func\"] = wf\n",
    "t2 = time.time()\n",
    "print(\"time: {}s\".format(t2-t1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Compiling data in a table using [pandas](https://pandas.pydata.org/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "    a [A]  c [A]  wf [eV]\n",
      "Co  2.507  4.069    5.569\n",
      "Mg  3.192  5.185    3.373\n",
      "Ru  2.706  4.282    5.305\n",
      "Zn  2.665  4.947    3.603\n"
     ]
    }
   ],
   "source": [
    "df = pd.DataFrame(hcp_dict).T\n",
    "df = df.rename(columns={'a': 'a [A]', \n",
    "                        'c': 'c [A]', \n",
    "                        'work_func': 'wf [eV]'})\n",
    "print(df.round(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda root]",
   "language": "python",
   "name": "conda-root-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.4"
  },
  "latex_envs": {
   "LaTeX_envs_menu_present": true,
   "autocomplete": true,
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 1,
   "hotkeys": {
    "equation": "Ctrl-E",
    "itemize": "Ctrl-I"
   },
   "labels_anchors": false,
   "latex_user_defs": false,
   "report_style_numbering": false,
   "user_envs_cfg": false
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
